<template>
  <div class="layout_billdetail">
    <!-- 新增提示 -->
    <!-- <div class="subWall">为了确保信息无误，请先填写身份信息</div> -->
    <ul class="list" id="billdetail">
      <li>
        推荐人手机：
        <input type="text" v-model="tel" @blur="checkNum" />
      </li>
      <li>
        推荐人姓名
        <input type="text" v-model="username" />
      </li>
    </ul>

    <div class="div1">
      <div class="div2">
        <button @click="authDeal()">确定</button>
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import moment from "moment";
import api from "../../assets/js/api";
export default {
  name: "billdetail",
  data() {
    return {
      tel: "",
      username: "",
      is_server: 0,
      id:'',
      order_sn:''
    };
  },
  created() {
    document.title = "现场推荐人";
  },
  mounted() {
    this.axios.defaults.baseURL = api;
    this.order_sn = location.hash.split(":")[1];
    // this.authAdd();
  },
  methods: {
    //实名认证提交
    checkNum() {
      let load = this.loading("加载中");
      if (!this.tel) {
        Toast({
          message: "请输入手机号",
          position: "bottom",
          duration: 2000
        });
        return false;
      }
      // console.log(this.resData)
      this.axios
        .post("/api/butler/is_valid_server", { recommend_phone: this.tel })
        .then(res => {
          if (res.data.code == 200) {
            console.log(res.data);

            this.username = res.data.data.server_name;
             console.log(this.username);
            this.is_server = res.data.data.is_server;
            this.id = res.data.data.server_id
            if (res.data.data.is_server == 0) {
              Toast({
                message: "请填写正确经销商推荐人",
                position: "bottom",
                duration: 2000
              });
            }
          } else if (res.data.code == 250) {
            Toast({
              message: "登录过期，请重新登陆",
              position: "bottom",
              duration: 2000
            });
            this.$router.push("/login");
            return false;
          } else {
            Toast({
              message: res.data.msg,
              position: "bottom",
              duration: 2000
            });
            return false;
          }
        })
        .catch(error => {
          load.hide();
          Toast({
            message: "请求失败，请稍后重试",
            position: "bottom",
            duration: 2000
          });
        });
    },
    //验证手机号
    authDeal() {
      if (this.is_server == 1) {
        localStorage.setItem('recommend_tel',this.tel)
        this.$router.push({
          path: "/createdBill:"+this.order_sn+'&recommend_tel:' + this.tel + "&recommend_name:" + this.username + "&recommend_id:" + this.id 
        });
      }
    }
  },
  beforeRouteLeave(to, from, next) {
         // 设置下一个路由的 meta
    to.meta.keepAlive = true;  // B 跳转到 A 时，让 A 缓存，即不刷新
    next();
  }

};
</script>
<style lang="less" scoped>
.div1 {
  position: absolute;
  bottom: 20px;
  width: 100%;
}
.div2 {
  display: flex;
  justify-content: center;
}
.my-shadow {
  position: fixed;
  top: 0px;
  left: 0px;
  opacity: 0.4;
  width: 100%;
  height: 100%;
  background-color: #333333;
  z-index: 100;
}

.my-dialog {
  z-index: 101;
  position: fixed;
  bottom: 0px;
  width: 100%;
  height: auto;
  min-height: 150px;
  background-color: #fff;
  overflow: scroll;
  max-height: 100%;
  .close {
    position: relative;
    height: 40px;
  }
  .box {
    display: flex;
    div {
      line-height: 30px;
      text-align: center;
      // width: 33%;
    }

    .box-1 {
      width: 30%;
    }
    .box-2 {
      width: 25%;
    }
    .box-3 {
      width: 45%;
    }
  }
  .my-top {
    div {
      font-weight: bold;
    }
  }
}

.my-button {
  float: right;
  margin-right: 10px;

  span {
    background-color: #ff94b1;
    color: #fff;
    font-size: 16px;
    line-height: 42px;
    height: 42px;
    margin-top: 3px;
    padding: 2px 5px;
    border-radius: 4px;
  }
}

.shadow-line {
  height: 10px;
  background-color: #cccccc;
  opacity: 0.2;
  clear: both;
}

.layout_billdetail {
  width: 100%;
  height: 100%;
  //padding-left: 15px;
  overflow: auto;
  font-size: 17px;
  color: #666;
  text-align: left;
}
.layout_billdetail .list {
  width: 100%;
  position: relative;
}
.list li {
  padding-left: 15px;
  min-height: 50px;
  line-height: 50px;
  border-bottom: 1px solid rgba(204, 204, 204, 0.3242);
  font-size: 17px;
  font-family: "PingFangSC-Medium";
  font-weight: 500;
  color: rgba(102, 102, 102, 1);
  position: relative;
  .tip {
    color: #ccc;
    margin-top: -25px;
  }
}

.line {
  position: relative;
  .member {
    position: absolute;
    right: 5px;
    top: 1px;

    span {
      background-color: #7d3a3a;
      color: #fff;
      border-radius: 6px;
      padding: 2px 4px;
    }
  }
}
.ivu-icon {
  height: 100%;
  line-height: 50px;
  font-size: 20px;
  float: right;
  margin-right: 15px;
}
span {
  height: 48px;
  line-height: 48px;
}
.noteBox {
  width: 95%;
  height: 120px;
  font-size: 17px;
  color: #888;
  border: 1px solid rgba(204, 204, 204, 0.3242);
  word-wrap: break-word;
  margin-bottom: 30px;
  padding-left: 8px;
}

//额外图片
.img {
  margin-top: 6px;
  p {
    height: 50px;
    line-height: 50px;
  }
}
.gray {
  width: 100%;
  height: 1px;
  margin-top: 10px;
  background: rgba(204, 204, 204, 0.2018);
}
//最多只三张图能
.photo {
  width: 100%;
  height: 110px;
}
.photo li {
  width: 90px;
  height: 90px;
  /* background-color: #d8d8d8; */
  margin-bottom: 10px;
  float: left;
  margin-right: 6px;
}
.photo li img {
  width: 90px;
  height: 90px;
  display: block;
}

// 底部经办人 放到右侧！
.right-line {
  font-size: 14px;
  text-align: right;
  margin-right: 6%;
  margin-bottom: 10px;
}
</style>


<style lang="less">
.ivu-modal-footer,
.ivu-modal-header {
  display: none !important;
}
.share {
  display: block;
  margin: 20px auto;
  font-size: 17px;
  letter-spacing: 1px;
}

.aicon {
  width: 70px;
  height: 30px;
  background-color: #fca3bb;
  border-radius: 0 0 10px 0;
  color: #fff;
  line-height: 30px;
  text-align: center;
}

.jiange {
  width: 110%;
  height: 10px;
  background-color: #f4f4f4;
  margin-left: -15px;
}

.row {
  min-height: 48px;
  line-height: 48px;
  background-color: #fff;
  text-align: left;
  padding-left: 15px;
  border-bottom: 1px solid rgba(204, 204, 204, 0.3242) !important;
  position: relative;
}
.allBox {
  position: relative;
}
.billendImg {
  width: 51px;
  height: 51px;
  position: absolute;
  right: 5px;
  top: 5px;
  z-index: 10;
}
.orderClass {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.subSqurt {
  width: 41px;
  height: 25px;
  background: rgba(234, 137, 137, 1);
  border-radius: 100px 0px 0px 100px;
  color: #fff;
  padding: 0 0 0 10px;
  font-size: 12px;
  line-height: 25px;
}
.subSqurt.all {
  background-color: #5f9bff;
}
.subSqurt.three {
  background-color: #a2a8fa;
}
.subSqurt.second {
  background-color: #f9a77f;
}
.subSqurt.first {
  background-color: #ff94b1;
}
.subWall {
  height: 34px;
  line-height: 34px;
  background-color: #fff6e0;
  padding: 0 15px;
}
.divs {
  width: 50%;
  float: left;
}
.fw {
  float: left;
  width: 100%;
}
.mt-popup {
  width: 100%;
  height: 100%;
}
</style>

